<?php

namespace Common\Model;

use Think\Model;

/*
 * 招聘信息
 */

class Entry2Model extends Model {

    protected $_auto = array(/* array(完成字段1,完成规则,[完成条件,附加规则]) */
        array('addTime', 'time', 1, 'function'),
        array('updateTime', 'time', 2, 'function'),
        array('isOn', '1', 1),
    );  // 自动完成定义

    /**
     * 获取一条
     */
    public function getEntry($id, $where = array(), $field = "*") {
        $where['entryID'] = $id;
        $rt = $this->field($field)->where($where)->find();
        return $rt;
    }

    /**
     * 获取品牌列表
     */
    public function getEntryList($pageNo = 1, $pageSize = 15, $where = array(), $order = array(), $field = "*") {
        $rt = $this->field($field)->where($where)->page("$pageNo,$pageSize")->order($order)->select();
        return $rt;
    }

    /**
     * 获取品牌列表总数
     */
    public function getEntryListLength($where = array()) {
        $result = $this->where($where)->count();
        return $result;
    }

    /**
     * 添加
     */
    public function addEntry($data = '') {
        $rt = false;
        if ($this->create($data)) {
            $rt = $this->add();
        }
        return $rt;
    }

    /**
     * 更新
     */
    public function updateEntry($data = '') {
        $rt = false;
        if ($this->create($data)) {
            $rt = $this->save();
        }
        return $rt;
    }

    /**
     * 编辑
     */
    public function editEntry($entryID) {
        $entry = $this->where("entryID = $entryID")->find();  //，find()返回一个一维数组，select()返回一个二维数组
        return $entry;          //返回一维数组
    }

    /**
     * 移除，只是隐藏，并非真的从数据库中删除数据
     */
    public function deleteEntry($entryID) {
        $data['isOn'] = 0;
        $data['entryID'] = $entryID;
        $entry = $this->save($data);
        return $entry;          //成功返回一个真值
    }

}

?>